<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AlterKfCustomerCouponUseHistoryAddColumnOrderID extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('customer_coupon_use_history', function (Blueprint $table) {

            $table->unsignedBigInteger('orderId')->default(0)->after('id')->comment('订单号');
            $table->unsignedInteger('serialNum')->default(0)->after('orderId')->comment('流水号');
            $table->unsignedTinyInteger('couponFrom')->default(0)->after('couponCode')
                  ->comment('优惠券来源 夸父, 美团, 抖音, 小红书');
            $table->unsignedTinyInteger('couponType')->default(0)->after('couponFrom')
                  ->comment('优惠券类型 1代金券 2套餐 3团购 4次卡');
            $table->string('couponTitle')->default('')->after('couponId')->comment('券名');
            $table->string('couponCostPrice')->default('')->after('couponId')->comment('券实收');
            $table->string('couponExtDiscountPrice')->default('')->after('couponCostPrice')->comment('券优惠金额');
            $table->string('createdBy')->default('')->after('createdByUid')->comment('人');
            $table->string('updatedBy')->default('')->after('createdByUid')->comment('人');

            $table->index('orderId', 'idx_orderId');
        });


    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {

        Schema::table('customer_coupon_use_history', function (Blueprint $table) {
            $table->dropColumn('orderId');
            $table->dropColumn('serialNum');
            $table->dropColumn('couponTitle');
            $table->dropColumn('couponFrom');
            $table->dropColumn('couponType');
            $table->dropColumn('couponCostPrice');
            $table->dropColumn('couponExtDiscountPrice');
            $table->dropColumn('createdBy');
            $table->dropColumn('updatedBy');
        });
    }
}
